// var CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlugin");
var path = require('path');
var webpack = require('webpack');
// var fs = require('fs');
// var srcDir = path.resolve(process.cwd(), 'app/js');

module.exports = {
    devtool: "#source-map",
    entry: {
        test:'./app/js/entry/test.js'
    },
    output: {
        path: path.join(__dirname, "dist/js/"),
        publicPath: "dist/js/",
        filename: "[name].js"
    },
    resolve: {
        alias: {
            'vue$': 'vue/dist/vue.common.js'
        }
    },
    module: {
        loaders: [
            {
                test: /\.js$/,
                loader: "babel",
                exclude: /node_modules/
            },
            {
                test:/\.vue$/,
                loader:'vue'
            }
        ]
    },
    babel: {
        presets: ['es2015','stage-0'],
        plugins: ['transform-runtime']
    },
    plugins: [
        //压缩和丑化，作用在js上面
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false
            },
            output: {
                comments: false
            }
        }),
        //直接定义第三方库 jquery经常使用的放在了这里
        // new webpack.ProvidePlugin({
        //     $: 'jquery'
        // })
        //定义公共chunk 这里是代码合并时使用的
        // new CommonsChunkPlugin({
        //     name: "commons",
        //     filename: "commons.js",
        //     minChunks: 2,
        //     chunks: ["index", "main"]
        // }),
        //将公共代码抽离出来合并为一个文件
        //new CommonsChunkPlugin('common.js')
    ]
};